<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/7/2
 * Time: 15:19
 */

namespace common\models\Service;


use common\models\DAO\Overdue;

class OverdueService {

    public static function get($userID){
        $overdue = Overdue::find()->where(array('userID'=>$userID))->groupBy('userID')
            ->select('SUM(overMoney) as overMoney, COUNT(`id`) as overAmount, userID')
            ->one_data();
        $overAmount = 0;
        if($overdue['overAmount'])
            $overAmount = $overdue['overAmount'];

        $result['overAmount'] = $overAmount;

        $overMoney = 0;
        if($overdue['overMoney'])
            $overMoney = $overdue['overMoney'];

        $result['overMoney'] = $overMoney;
        return $result;
    }
}